<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>success</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        tr:nth-child(odd) {
            background-color: #fcf8e3;
        }
    </style>
</head>
<body>
<div class="page-header">
    <h2>
        <small style="margin-left: 36px;">流动人口管理系统</small>
        <a   id="link1" href="${pageContext.request.contextPath}/firstPage" style="margin-left: 800px;font-size: 15px; color: #888888">首页</a>
        <a  id="link2" href="${pageContext.request.contextPath}/child" style="margin-left: 20px;font-size: 15px; color: #888888">子女信息</a>
        <a id="link3" href="${pageContext.request.contextPath}/externalPopulation" style="margin-left: 20px;font-size: 15px; color: #888888">流动人口</a>
        <a id="link4" href="${pageContext.request.contextPath}/residentialPass"  style="margin-left: 20px;font-size: 15px; color: #888888">登记信息</a>
    </h2>
</div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">
                <div class="tabbable" id="tabs-439757" >
                    <ul class="nav nav-tabs" style="width: 1300px;margin-left: 60px; margin-top: 40px">
                        <li class="active">
                            <a href="#panel-370485" data-toggle="tab">已办理居住证</a>
                        </li>
                        <li>
                            <a href="#panel-176775" data-toggle="tab">未办理居住证</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="panel-370485" style="margin-left: 92px;">
                            <p>
                            <ul class="breadcrumb" style=" background-color: rgb(255, 255, 255);">
                                <li>
                                    <a href="${pageContext.request.contextPath}/firstPage">主页</a>
                                    <span class="divider"> »</span>
                                </li>
                                <li class="active">
                                    流动人口登记信息
                                    <span class="divider"> »</span>
                                </li>
                            </ul>
                            <table id="tab" class="table table-bordered table-hover"
                                   style="overflow:hidden;border: 2px #000;border-radius: 3px;width:1200px;margin-left: 42px">
                                <thead>
                                <tr class="info">
                                    <td>姓名</td>
                                    <td>性别</td>
                                    <td>民族</td>
                                    <td>身份证号</td>
                                    <td>户籍所在地</td>
                                    <td>现居住地</td>
                                    <td>操作</td>
                                </tr>
                                </thead>

                                <c:forEach items="${residentialPasses}" var="residentialPasse">
                                    <tr>
                                        <td>${residentialPasse.name}</td>
                                        <td>${residentialPasse.sex}</td>
                                        <td>${residentialPasse.national}</td>
                                        <td>${residentialPasse.ID_number}</td>
                                        <td>${residentialPasse.domicile_place}</td>
                                        <td>${residentialPasse.address}</td>
                                        <td>
                                            <button id="update" class="btn btn-warning" style="margin-right: 10px">修改
                                            </button>
                                            <button id="delete" class="btn btn-danger">删除</button>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </table>


                        <a href="${pageContext.request.contextPath}/residentialPass/addRPage"
                           style="margin-left: 1130px">
                            <button class="btn btn-info">添加登记信息</button>
                        </a>
                        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                            <div class="modal-dialog" role="document">
                                <form action="${pageContext.request.contextPath}/residentialPass/updateR" method="post">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h4 class="modal-title" id="myModalLabel">修改信息</h4>
                                        </div>
                                        <div class="modal-body">

                                            <div class="form-group">
                                                <label for="name">姓名：</label>
                                                <input type="text" class="form-control" id="name" name="name"></br>
                                            </div>
                                            <div class="form-group">
                                                <label for="sex">性别：</label>
                                                <input type="text" class="form-control" name="sex" id="sex"></br>
                                            </div>
                                            <div class="form-group">
                                                <label for="national">民族：</label>
                                                <input type="text" class="form-control" name="national"
                                                       id="national"></br>
                                            </div>
                                            <div class="form-group">
                                                <label for="ID_number">身份证号：</label>
                                                <input type="text" class="form-control" id="ID_number"
                                                       name="ID_number"></br>
                                            </div>
                                            <div class="form-group">
                                                <label for="domicile_place">户籍所在地：</label>
                                                <input type="text" class="form-control" id="domicile_place"
                                                       name="domicile_place"></br>
                                            </div>
                                            <div class="form-group">
                                                <label for="address">现居住地：</label>
                                                <input type="text" class="form-control" id="address"
                                                       name="address"></br>
                                            </div>

                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-default" data-dismiss="modal"><span
                                                    class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭
                                            </button>
                                            <input type="submit" class="btn btn-primary" value="保存">
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="modal fade" id="deleteChild" tabindex="-1" role="dialog">
                            <div class="modal-dialog" role="document">
                                <form action="${pageContext.request.contextPath}/residentialPass/deleteR" method="post">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">&times;</span></button>
                                            <h4 class="modal-title">删除信息</h4>
                                        </div>
                                        <div class="modal-body">
                                            <h3>
                                                是否删除<input type="text" id="deleteName"
                                                           style="background-color:transparent;border:0;" disabled/>
                                                <input type="text" id="ID" name="ID" readonly style="display:none;"/>
                                            </h3>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                                <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭
                                            </button>
                                            <input type="submit" class="btn btn-primary" value="保存">
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        </div>
                        <div class="tab-pane" id="panel-176775" >
                            <iframe class="iframeurl" frameborder="0" style=" margin-top:9px;height: 100%;width: 100%" src="/undocumentedWorkers"  seamless></iframe>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script>
    //注册新增按钮的事件
    $(function () {

        $("#tab").on("click", "#update", function (event) {
            $('#myModal').modal();
            $("#name").val($(this).closest("tr").find("td").eq(0).text());
            $("#sex").val($(this).closest("tr").find("td").eq(1).text());
            $("#national").val($(this).closest("tr").find("td").eq(2).text());
            $("#ID_number").val($(this).closest("tr").find("td").eq(3).text());
            $("#domicile_place").val($(this).closest("tr").find("td").eq(4).text());
            $("#address").val($(this).closest("tr").find("td").eq(5).text());
        });
        $("#tab").on("click", "#delete", function (event) {
            $('#deleteChild').modal();
            $("#deleteName").val($(this).closest("tr").find("td").eq(0).text());
            $("#ID").val($(this).closest("tr").find("td").eq(3).text());
        });
    });
    var url=window.location.href;
    var type=url.split('#')[1];
    console.log(url)
    if(type=="undocumentedWorkers"){
        $('#tabs-439757 a[href="#panel-176775"]').tab('show')
    }
</script>
